//
// Created by xm on 2024/4/28.
//

#include "test03.h"
#include "iostream"

using namespace std;

#define ADD(x,y) x+y

inline int F_ADD(int x, int y){
    return x + y;
}

static void  demo1(){
    cout << "test03" << endl;

    int r1 = ADD(10, 20) * 2;
    cout << "r1= " << r1 << endl;

    int r2 = F_ADD(10, 20) * 2;
    cout << "r2= " << r2 << endl;
}

static void  swap(int *a, int *b){
    int  tmp = *a;
    *a = *b;
    *b = tmp;
}

static void  swap2(int &a, int &b){
    int tmp = a;

    printf("a=%d b=%d tmp=%d \n", a, b, tmp);
    a = b;
    printf("a=%d b=%d tmp=%d \n", a, b, tmp);
    b = tmp;
    printf("a=%d b=%d tmp=%d \n", a, b, tmp);
}

static void  demo2()
{
    int  a = 10;
    int  b = 20;

//    swap(&a, &b);
//    printf("a=%d  b=%d \n", a, b);

    swap2(a, b);
    printf("a=%d  b=%d \n", a, b);
}

void test03(){

    demo2();


}